import 'package:equatable/equatable.dart';

class ExampleItem extends Equatable {
  final int id;
  final String title;
  final String description;
  final String imageUrl;
  final DateTime createdAt;
  final bool isActive;
  
  const ExampleItem({
    required this.id,
    required this.title,
    required this.description,
    required this.imageUrl,
    required this.createdAt,
    required this.isActive,
  });
  
  @override
  List<Object?> get props => [
    id,
    title,
    description,
    imageUrl,
    createdAt,
    isActive,
  ];
  
  ExampleItem copyWith({
    int? id,
    String? title,
    String? description,
    String? imageUrl,
    DateTime? createdAt,
    bool? isActive,
  }) {
    return ExampleItem(
      id: id ?? this.id,
      title: title ?? this.title,
      description: description ?? this.description,
      imageUrl: imageUrl ?? this.imageUrl,
      createdAt: createdAt ?? this.createdAt,
      isActive: isActive ?? this.isActive,
    );
  }
  
  Map<String, dynamic> toMap() {
    return {
      'id': id,
      'title': title,
      'description': description,
      'imageUrl': imageUrl,
      'createdAt': createdAt.toIso8601String(),
      'isActive': isActive,
    };
  }
  
  factory ExampleItem.fromMap(Map<String, dynamic> map) {
    return ExampleItem(
      id: map['id'] ?? 0,
      title: map['title'] ?? '',
      description: map['description'] ?? '',
      imageUrl: map['imageUrl'] ?? '',
      createdAt: DateTime.parse(map['createdAt'] ?? DateTime.now().toIso8601String()),
      isActive: map['isActive'] ?? false,
    );
  }
}